import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

// invocation handler is specific for dynamic proxys
public class CarHandler implements InvocationHandler {
	private Cars c;
	
	public CarHandler(Cars c) {
		this.c = c;
	}
	// a generic invocation
	@Override
	//this method will be invoked on an invocation handler 
	//when a method is invoked on a proxy instance that it is associated with 
	//	proxy - the proxy instance that the method was invoked on
    //	method - the Method instance corresponding to the interface method invoked on the proxy instance
	//  args - an array of objects containing the values of the arguments passed in the method invocation on the proxy instance
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		System.out.println("Invoking: " + method.getName());
		// call framework
		return method.invoke(c, args);
	}

}
